﻿using System;
using System.Collections;
using System.Collections.Generic;
using Sandy.Queries;

namespace Sandy.Selectors
{
    // Path: client.SuperFamily("name")["key"]
    public class SuperColumnGetSelector
    {
        private readonly SandyClient _client;
        private readonly SandyFamily _family;
        private readonly string _key;

        public SuperColumnGetSelector(SandyClient client, SandyFamily family, string key)
        {
            _client = client;
            _family = family;
            _key = key;
        }

        public SubColumnGetSelector this[string superCol]
        {
            get
            {
                return new SubColumnGetSelector(_client, _family, _key, superCol);
            }
        }

        public IDictionary<string, IDictionary<string, string>> this[IEnumerable<string> superCols]
        {
            get
            {
                // throw new NotImplementedException("request 7: get_slice(cf={0}, key={1}, scols={2})");
                return GetSliceQuery.PerformSuper(_client, _family, _key, superCols);
            }
        }

        public IDictionary<string, IDictionary<string, string>> this[params string[] superCols]
        {
            get
            {
                // Request 8
                return this[(IEnumerable<string>) superCols];
            }
        }

        public IDictionary<string, IDictionary<string, string>> this[Range superColRange]
        {
            get
            {
                // throw new NotImplementedException("request 9: get_slice(cf={0}, key={1}, scolRange={2})");
                return GetSliceQuery.PerformSuper(_client, _family, _key, superColRange);
            }
        }

        public IDictionary<string, IDictionary<string, string>> AllColumns
        {
            get
            {
                return this[Range.AllInclusive];
            }
        }
    }
}